<form name="department" class="form-horizontal form-row-seperated validator-dialog form-ajax" action="<?=url('department/save')?>" method="post">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
        <h4 class="modal-title">
            <i class="fa fa-<?=on($department, 'pencil', 'plus')?>"></i>
            <?=__($department ? 'Edit Department' : 'Add Department')?>
        </h4>
    </div>
    <div class="modal-body form">
        <input type="hidden" name="dept_id" value="<?=array_get($department, 'dept_id', 0)?>" />
        <div class="form-body">
            <div class="form-group">
                <label class="col-sm-4 control-label"><?=__('Parent Dept')?></label>
                <div class="col-sm-8">
                    <select name="parent_id" class="form-control input-medium">
                        <option value="0"><?=__('Select...')?></option>
                        <? foreach ($departments as $dept): ?>
                            <option value="<?=$dept['dept_id']?>" <?=on(array_get($department, 'parent_id') == $dept['dept_id'], 'selected')?>>
                                <?=str_repeat('&nbsp; ', $dept['level']*4)?>
                                <?=db_translate($dept['department'], 'department', $dept['dept_id'])?>
                            </option>
                        <? endforeach; ?>
                    </select>
                </div>
            </div>
            <? foreach ($langs as $l => $t): ?>
            <div class="form-group">
                <label class="col-sm-4 control-label">
                    <span class="required">*</span>
                    <?=__('Dept Name', null, $l)?> (<?=$t?>)
                </label>
                <div class="col-sm-8">
                    <input type="text" name="department[<?=$l?>]" class="form-control input-large" value="<?=array_get($department, 'department.' . $l)?>" data-required="<?=__('Dept name is required')?>" />
                </div>
            </div>
            <? endforeach; ?>
            <div class="form-group last">
                <label class="col-sm-4 control-label"><?=__('Display Order')?></label>
                <div class="col-sm-8">
                    <input type="text" name="sort_order" class="form-control input-inline input-small" value="<?=array_get($department, 'sort_order', 99)?>" data-number="<?=__('Invalid sort number')?>">
                    <span class="help-inline"><?=__('The larger the number the more front')?></span>
                </div>
            </div>
        </div>
    </div>
    <div class="modal-footer">
        <button type="submit" class="btn btn-primary">
            <i class="fa fa-check"></i>
            <?=__('Submit')?>
        </button>
        <button type="button" class="btn btn-default" data-dismiss="modal">
            <i class="fa fa-times"></i>
            <?=__('Close')?>
        </button>
    </div>
</form>
